package com.cj.springtest2.dao.impl;

import com.cj.springtest2.dao.IAddressDetailDao;
import com.cj.springtest2.model.AddressDetail;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

/**
 * Created by huangyin on 2016/11/2.
 */
@Repository(value = "addressDetailDao")
public class AddressDetailDaoImpl extends BasicDaoImpl implements IAddressDetailDao {
    @Resource
    private IAddressDetailDao addressDetailDao;

    public void save(AddressDetail address) {
        addressDetailDao.save(address);
        session.commit();  //一定要记得commit
    }

    public int findNewestInsertId() {
        return addressDetailDao.findNewestInsertId();
    }

    public boolean update(AddressDetail address) {
        addressDetailDao.update(address);
        session.commit();  //一定要记得commit
        return true;
    }

    public boolean delete(int id) {
        addressDetailDao.delete(id);
        session.commit();  //一定要记得commit
        return true;
    }

    public AddressDetail findById(int id) {
        return addressDetailDao.findById(id);
    }

    @Override
    protected void registerDao() {
        addressDetailDao = session.getMapper(IAddressDetailDao.class);
    }
}
